package com.sumainfor.pc.gmio.controller.secretary;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.gmio.service.SeOverflowService;
import com.sumainfor.pc.gmio.service.SePaymentHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 服务秘书 账单溢出
 */
@RestController
@RequestMapping("/secretary/SePaymentHistory")
public class SeOverflowController implements Serializable {
    @Autowired
    private SeOverflowService seOverflowService;
    @Autowired
    private SePaymentHistoryService sePaymentHistoryService;
    /**
     * 查询账单的溢出信息
     */
    @GetMapping("/getOverflowBySouId")
    public JsonResult getOverflowBySouId(@RequestParam Map<String,Object>params){
        JsonResult result=new JsonResult();
        Map<String,Object> dataMap=new HashMap<String,Object>();
        if (params.get("SouId")==null){
            return result.putFailed("参数不正确");
        }
        Map<String,Object> map =seOverflowService.getOverflowBySouId(params);
        List<Map<String,Object>> list =sePaymentHistoryService.getPaymentHistory(params);
        if (map==null && list==null){
            result.putFailed("服务器繁忙");
        }else{
            if (map!=null){
                dataMap.put("payData",map);
            }else{
                dataMap.put("payData",new HashMap<String,Object>());
            }
            if (list!=null){
                dataMap.put("payList",list);
            }else{
                dataMap.put("payList",new ArrayList<Map<String,Object>>());
            }
            result.put(dataMap);
        }
        return result;
    }
    /**
     * 服务秘书审核账单的时候根据租客编号查询账单的溢出信息
     */
    @GetMapping("/getSeOverflowList")
    public JsonResult getSeOverflowList(@RequestParam Map<String,Object>params){
        return seOverflowService.getSeOverflowList(params);
    }
    /**
     * 服务秘书审核账单的时候根据租客编号查询账单的溢出信息
     */
    @PostMapping("/updateSeDeduction")
    public JsonResult updateSeDeduction(@RequestBody Map<String,Object>params){
        return seOverflowService.updateSeDeduction(params);
    }

}
